package com.dycc.attch_componet.adapter;

import android.content.Context;
import android.view.View;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.dycc.attch_componet.R;
import com.dycc.attch_componet.adapter.holder.VideoNormalHolder;
import com.dycc.libary.http.commonbean.attach.VideoBean;

import java.util.List;

/**
 * 视频播放适配器
 * Created by wxk on 2018/1/24 0024.
 */

public class VideoPlayerAdapter extends BaseQuickAdapter<VideoBean,VideoNormalHolder> {
   Context context;
    onDownloadListener downloadListener;
    onSharedListener sharedListener;

    public VideoPlayerAdapter(List<VideoBean> videos, Context context){
        super(R.layout.vedio_normal_item,videos);
        this.context=context;
    }

    public void setDownloadListener(onDownloadListener downloadListener) {
        this.downloadListener = downloadListener;
    }

    public void setSharedListener(onSharedListener sharedListener) {
        this.sharedListener = sharedListener;
    }

    @Override
    protected void convert(VideoNormalHolder helper, final VideoBean item) {
        helper.getVideoplayer().setUp(item.getUrl(),item.getTitle());
        Glide.with(context).load(item.getSmall_icon()).into(helper.getVideoplayer().ivThumb);
        helper.getShowDownloadLinearlayout().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {//下载
                   downloadListener.onDownload(view,item);
            }
        });
        helper.getShowShareLinearlayout().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {//分享
                sharedListener.onSharedListener(view,item);
            }
        });
    }

    public interface  onDownloadListener{
          void onDownload(View view,VideoBean item);
    }

    public interface  onSharedListener{
        void onSharedListener(View view,VideoBean item);
    }
}